﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace Workbench.Presentation
{
    public static class HashSetExtensions
    {
        public static void ForEach<T>(this HashSet<T> collection, Action<T> action)
        {
            foreach (var item in collection)
            {
                action(item);
            }
        }
    }

    public static class UserControlExtensions
    {
        public static Window GetWindow(this UserControl uc)
        {
            var parent = VisualTreeHelper.GetParent(uc);
            while (!(parent is Window))
            {
                parent = VisualTreeHelper.GetParent(parent);
                if(parent == null) break;
            }
            return parent as Window;
        }
    }
}
